import React, { useEffect, useState } from "react";
import { Button, message } from "antd";
const MyButton = (props) => {
  const [title, setTitle] = useState("默认Title");
  useEffect(()=>{
      if (props && props.title) {
        setTitle(props.title)
      }
  },[])
  const showTitle = () => {
    message.success(title);
  };
  return (
    <div>
      <h1>{props.title ? props.title : "默认Title"}</h1>
      <Button type="primary" onClick={showTitle}>
        点击我试一下?
      </Button>
    </div>
  );
};

export default MyButton;
